package com.iknow.net.translate;

import android.content.Context;
import com.iknow.data.Word;
import com.iknow.net.translate.impl.IKDictTranslate;
import com.iknow.net.translate.impl.IKIcibaTranslate;
import com.iknow.util.StringUtil;

public class IKTranslateManager
{
  private Context mContext;
  private IKTranslate translate = null;

  public IKTranslateManager(Context paramContext)
  {
    this.mContext = paramContext;
  }

  public Word translate(String paramString, boolean paramBoolean)
  {
    Object localObject;
    if ((StringUtil.isEmpty(paramString)) || (paramString.contains("’")))
      localObject = null;
    while (true)
    {
      while (true)
      {
        while (true)
        {
          return localObject;
          Word localWord1 = translateLocal(paramString, paramBoolean);
          if ((localWord1 == null) || (StringUtil.isEmpty(localWord1.getPron())))
            break;
          localObject = localWord1;
        }
        if (this.translate == null)
          this.translate = new IKIcibaTranslate();
        Word localWord2 = this.translate.translate(paramString, paramBoolean);
        if ((localWord2 == null) || (StringUtil.isEmpty(localWord2.getPron())))
          break;
        localObject = localWord2;
      }
      localObject = new IKDictTranslate().translate(paramString, paramBoolean);
    }
  }

  public Word translateLocal(String paramString, boolean paramBoolean)
  {
    Object localObject;
    if ((StringUtil.isEmpty(paramString)) || (paramString.contains("’")))
      localObject = null;
    while (true)
    {
      while (true)
      {
        return localObject;
        if (this.translate == null)
          this.translate = new IKIcibaTranslate();
        Word localWord = this.translate.translateLocal(paramString, paramBoolean);
        if ((localWord == null) || (StringUtil.isEmpty(localWord.getPron())))
          break;
        localObject = localWord;
      }
      localObject = new IKDictTranslate().translateLocal(paramString, paramBoolean);
    }
  }

  public static abstract interface IKTranslate
  {
    public abstract Word translate(String paramString, boolean paramBoolean);

    public abstract Word translateLocal(String paramString, boolean paramBoolean);
  }
}